/**
 * 
 */
package com.et114.modules.products.procontent.services;

import com.et114.core.services.impl.BaseServicesImpl;
import com.et114.modules.products.commons.Context;
import com.et114.modules.products.procontent.dao.ProContentDao;
import com.et114.modules.products.procontent.vo.ProContent;

/*
 * @author guanhw
 */
public class ProContentServiceImpl extends BaseServicesImpl {
	private ProContentDao proContentDao ;

	public void setProContentDao ( ProContentDao proContentDao ) {
		this.proContentDao = proContentDao;
	} 
	public ProContent getProContent( ProContent pc ) throws Exception { 
		return proContentDao.getProContent ( pc ) ;
	}
	
	
	public ProContent getProContentCacheModel( ProContent pc ) throws Exception { 
		return proContentDao.getProContentCacheModel ( pc ) ;
	}
	
	
	public Long saveProContent( ProContent pc  ) throws Exception {
		return proContentDao.saveProContent ( pc ) ; 
	}
	
	public void updateProContent( ProContent pc ) throws Exception {
		proContentDao.updateProContent ( pc ) ; 
		
	}
	
	
	public void saveAndUpdateProContent ( ProContent pc ) throws Exception {
		ProContent content = getProContent( pc ) ;
		if ( content != null ) {
			content.setContent ( pc.getContent ( ) ) ; 
			updateProContent( content ) ; 
		}
		else saveProContent( pc ) ;
		
		Context.doCommpass4ProImage ( pc.getProId ( ) , pc.getProType ( ) ) ;
	}
	
	public ProContent getProContentById( Long contentId  ) throws Exception { 
		return proContentDao.getProContentById ( contentId ) ;
	}
	
	public void removeProContent( ProContent pc ) throws Exception {
		proContentDao.removeProContent ( pc ) ;
	}
}
